<template>
  <el-dialog
    :title="title"
    :visible.sync="openSheet"
    width="50%"
    :destroy-on-close="true"
    :close-on-click-modal="false"
  >
    <el-form ref="form" :model="form" disabled :label-width="labelWidth">
      <el-row>
        <el-col :span="24">
          <el-form-item :label="$t('departmentCode')">
            <el-input
              v-model="form.code"
            />
          </el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item :label="$t('departmentName')">
            <el-input
              v-model="form.name"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="cancel">{{ $t('cancel') }}</el-button>
    </div>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      title: undefined,
      openSheet: false,
      form: {}
    };
  },
  computed: {
    labelWidth() {
      return this.$i18n.locale === 'en' ? '150px' : '80px';
    }
  },
  methods: {
    async openSheetDialog(data) {
      this.openSheet = !this.openSheet;
      this.title = this.$t('departmentsInquireTitle');
      this.form = data;
    },
    cancel() {
      this.openSheet = !this.openSheet;
    }
  }
};
</script>

<style scoped>
.el-input input, .table-select .el-input__inner {
    width: 220px;
    box-sizing: border-box;
}
::v-deep .el-form-item__label {
    text-align: right;
}
</style>

